package com.suncaper.han_yi_system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.suncaper.han_yi_system.mapper.BatchMapper;
import com.suncaper.han_yi_system.pojo.entity.Batch;
import com.suncaper.han_yi_system.pojo.entity.LoginUser;
import com.suncaper.han_yi_system.service.BatchService;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BatchServiceImpl extends ServiceImpl<BatchMapper, Batch> implements BatchService {
    @Override
    public Batch findMyBatch() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        LoginUser loginUser = (LoginUser)authentication.getPrincipal();
        Long userId = loginUser.getUser().getId();
        return getBaseMapper().findMyBatch(userId);
    }

    @Override
    public int saveClothingStyle(List<Long> ids, Long batchId) {
        return getBaseMapper().saveClothingStyle(batchId,ids);
    }

    @Override
    public int deleteClothingStyle(Long batchId, List<Long> ids) {
        return getBaseMapper().deleteClothingStyle(batchId,ids);
    }


}